package com.shi.shiro.common;

import cn.hutool.core.util.ObjUtil;
import com.shi.shiro.domain.User;

public class UserHolder {
    
    private static ThreadLocal<User> threadLocal=new ThreadLocal<>();
    
    public static User getUser(){
        return threadLocal.get();
    }
    
    public static void setUser(User User){
        if (ObjUtil.isEmpty(getUser())) {
            threadLocal.set(User);
        }
    }
    
    public static void removeUser(){
        if (ObjUtil.isNotEmpty(getUser())) {
            threadLocal.remove();
        }
    }
}
